using UnityEngine;
using UnityEngine.UI;
using QFramework;
using UnityEngine.SceneManagement;

namespace QFramework.Example
{
	public class UIGamePassPanelData : UIPanelData
	{
	}
	public partial class UIGamePassPanel : UIPanel
	{
		protected override void OnInit(IUIData uiData = null)
		{
			mData = uiData as UIGamePassPanelData ?? new UIGamePassPanelData();
			// please add init code here

			// 游戏通关时，游戏时间暂停
			Time.timeScale = 0;
			// 用qfarmework的actionkit来监听update，和把按键行为写在update里一样
			ActionKit.OnUpdate.Register((() =>
			{
				if (Input.GetKeyDown(KeyCode.Space))
				{
					Global.ResetDate();
					this.CloseSelf();
					SceneManager.LoadScene("Game");
				}
			}));
			
			BtnBackToStart.onClick.AddListener(() =>
			{
				//Global.ResetDate();
				this.CloseSelf();
				SceneManager.LoadScene("GameStart");
			});

			AudioKit.PlaySound("game_pass");
		}
		
		protected override void OnOpen(IUIData uiData = null)
		{
		}
		
		protected override void OnShow()
		{
		}
		
		protected override void OnHide()
		{
		}
		
		protected override void OnClose()
		{
			//Time.timeScale = 1.0f;
		}
	}
}
